//
//  ViewController.m
//  UI去哪网页面作业
//
//  Created by dllo on 16/2/29.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "MyTableViewCell.h"
#import "MyxiaTableViewCell.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,retain)UITableView *tableView;
@property(nonatomic,retain)NSMutableArray *keyArr;
@property(nonatomic,retain)NSDictionary *dataDic;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor=[UIColor yellowColor];
    self.tableView=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    
    [self data];
  
    
    
}
-(void)data{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];
  
    
    self.keyArr = [NSMutableArray arrayWithContentsOfFile:path];
    NSLog(@"%@", self.keyArr);
    ;
    

}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;


}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     NSDictionary *dic =self.keyArr[indexPath.row];
    if ([dic[@"type"] isEqualToString:@ "1"]) {
        
    
     MyTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell=[[MyTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    
     self.tableView.rowHeight=250;
    }
   
    
    cell.label.text=dic[@"text1 - 2"];
   cell.label1.text=dic[@"text5"];
    cell.label2.text=dic[@"text1"];
    cell.label3.text=dic[@"text3"];
    cell.label4.text=dic[@"text6"];
    cell.label5.text=dic[@"text2"];
    cell.label6.text=dic[@"text4"];
    cell.label7.text=dic[@"text2"];
    cell.imageView.image=[UIImage imageNamed:@"1.jpg"];
        
        
         return cell;
        
    }else{
        MyxiaTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
        if (!cell) {
            cell=[[MyxiaTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
            
               self.tableView.rowHeight=180;
        }
        
        
        cell.label.text=dic[@"text5"];
//        cell.label1.text=dic[@"text5"];
        cell.label2.text=dic[@"text1"];
        cell.label3.text=dic[@"text3"];
        cell.label4.text=dic[@"text6"];
        cell.label5.text=dic[@"text2"];
        cell.label6.text=dic[@"text4"];
//        cell.label7.text=dic[@"text2"];
        
        if (indexPath.row==1) {
            
        
          
            cell.myimageView.image=[UIImage imageNamed:@"2.jpg"];}else if (indexPath.row==2){
            
            cell.myimageView.image=[UIImage imageNamed:@"3.jpg"];
                cell.label.backgroundColor=[UIColor greenColor];
                cell.label2.backgroundColor=[UIColor greenColor];
                cell.label3.backgroundColor=[UIColor greenColor];
                cell.label4.backgroundColor=[UIColor greenColor];
                cell.label5.backgroundColor=[UIColor greenColor];
                cell.label6.backgroundColor=[UIColor greenColor];

                
                
            
            
            }else if (indexPath.row==3){
                cell.myimageView.image=[UIImage imageNamed:@"4.jpg"];
                cell.label.backgroundColor=[UIColor orangeColor];
                cell.label2.backgroundColor=[UIColor orangeColor];
                cell.label3.backgroundColor=[UIColor orangeColor];
                cell.label4.backgroundColor=[UIColor orangeColor];
                cell.label5.backgroundColor=[UIColor orangeColor];
                cell.label6.backgroundColor=[UIColor orangeColor];
            
            }else{
                cell.myimageView.image=[UIImage imageNamed:@"5.jpg"];
                cell.label.backgroundColor=[UIColor purpleColor];
                cell.label2.backgroundColor=[UIColor purpleColor];
                cell.label3.backgroundColor=[UIColor purpleColor];
                cell.label4.backgroundColor=[UIColor purpleColor];
                cell.label5.backgroundColor=[UIColor purpleColor];
                cell.label6.backgroundColor=[UIColor purpleColor];
                
            }
        return cell;

    
     
    
    
    
    
    }
   

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
